<?php
/** $Id: default_form.php 11917 2009-05-29 19:37:05Z ian $ */
defined( '_JEXEC' ) or die( 'Restricted access' );

	$input_firstname = JText::_( 'Udfyld venligst rubrikken: &quot;Fornavn&quot;' );
	$input_lastname = JText::_( 'Udfyld venligst rubrikken: &quot;Efternavn&quot;' );
	$input_company = JText::_( 'Udfyld venligst rubrikken: &quot;Firmanavn&quot;' );
	$input_address = JText::_( 'Udfyld venligst både &quot;Adresse&quot;' );
	$input_post = JText::_( 'Udfyld venligst både &quot;Postnr&quot;' );
	$input_city = JText::_( 'Udfyld venligst både &quot;By&quot;' );
	$input_email = JText::_( 'Indtast venligst en gyldig e-mail-adresse' );
	$input_email_invalid= JText::_( 'De to indtastede e-mail-adresser er ikke ens' );
	$input_tel = JText::_( 'Indtast venligst et 8-cifret telefonnummer' );
	
	$input_confirmemail = JText::_( 'De to indtastede e-mail-adresser er ikke ens' );
	$input_address1 = JText::_( 'Udfyld venligst både &quot;Adresse&quot;' );
	$input_post1 = JText::_( 'Udfyld venligst både &quot;Postnr&quot;' );
	$input_city1 = JText::_( 'Udfyld venligst både &quot;By&quot;' );
	//$job_rule = JText::_( 'Jeg accepterer brugerbetingelserne ?' );
	$job_rule = JText::_( 'Du skal markere, at du acceptere brugerbetingelserne,for at kunne gå videre' );
		
	$session = JFactory::getSession();
	$app = JFactory::getApplication();
	$template = JURI::base() . 'templates/' . $app->getTemplate();
	
	
	$popup =  JRequest::getVar( 'popup','','get' ); 
	$receivedemail = "";
	 if($popup==1) {
		  $receivedemail = JRequest::getVar( 'receivedemail','','get' );
		 ?>
         <script type="text/javascript">
		 $(document).ready(function() {
			  resetDiv();
       		  $('#msg_thanks').click();		
		});	  
		 </script> 	  
         <?php
	 }
?>
<script type="text/javascript">
	
</script>
<script type="text/javascript">
	$(document).ready(function() {
		
		$('.prtext').focus(function() {
			value=$(this).val();
			$(this).attr("value","");
		});
		$('.prtext').blur(function() {
			if($(this).val()=="") {
				$(this).val(value);
			}
		});
	});

function button_submit(){}
		
	   
$(document).ready(function($) {	
	   
	  /*					   
	   $("#submitbtn").click(function() {
			  if(jQuery("#opretOpgavebeskrivelseForm").valid())
			  {
	  			   alert('valit');				   
			  }
			  
		});
	  */ 
	   $("#job_tel").mask("99999999",{placeholder:""});  
	   $("#job_post").mask("9999",{placeholder:""});  
	   $("#job_post1").mask("9999",{placeholder:""}); 
	    
	   $.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		if(value<1000) return false;	
		if(value>=3800 && value <=3999) return false;
		
		return /^\d{4}$/.test(value); 
	   }, '');
	   
	   
	   $.validator.addMethod('defaultphone', function(value) {													   			return /^\d{8}$/.test(value); 		
		});
		
		$.validator.addMethod('companycheck', function(value) {													   
			if($('#usertype2').is(":checked")==true) { 
				if(value=='') {return false;} else { return true;}
			}	else { 	return true; }			
		});
		
		$.validator.addMethod('address1', function(value) {													   
			if($('#job_workataddress2').is(":checked")==true) { 
				if(value=='') {return false;} else { return true;}
			}	else { 	return true; }			
		});
		$.validator.addMethod('post1', function(value) {													   
			if($('#job_workataddress2').is(":checked")==true) { 
				return /^\d{4}$/.test(value); 
			}	else { 	return true; }			
		});
		$.validator.addMethod('city1', function(value) {													   
			if($('#job_workataddress2').is(":checked")==true) { 
				if(value=='') {return false;} else { return true;}
			}	else { 	return true; }			
		});

		$("#opretOpgaverKontaktInfoForm").validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				$('#msgbox').html(validator['errorList'][0]['message']);
    			$('.btnhidden').click();
            	$('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				$('#TB_overlay').attr("onclick","close_popup();");
				$('#TB_closeWindowButton').attr("onclick","close_popup();");
				
				var erro_len = validator['errorList'].length;
				//alert(errors);
				
				$("#opretOpgaverKontaktInfoForm input").removeClass("border_red");
				$("#opretOpgaverKontaktInfoForm textarea").removeClass("border_red");
				for($i=0;$i<errors;$i++) {
					$('#'+validator['errorList'][$i]['element'].name).addClass("border_red");
				}
			  } else {
			  }
			},
			rules: {
                job_firstname : "required",
				job_lastname : "required",			
				job_company : "companycheck",			
				job_address : "required",
				job_post: {
					required: true,
					postalcode: true
				},
				job_city: "required",
				job_email: {
					required: true,
					email: true
				},	
				job_confirmemail: {
					required: true,
					equalTo:"#job_email"
				},	
				job_tel:  {
					required: true,
					defaultphone: true
				},	
				job_address1: "address1",
				job_post1: "post1",
				job_city1: "city1",
				accept_rule:"required"
			},
			messages: {
                job_firstname: "<?php echo $input_firstname; ?>",
				job_lastname: "<?php echo $input_lastname; ?>",
				job_company: "<?php echo $input_company; ?>",
				job_address: "<?php echo $input_address; ?>",
				job_post: "<?php echo $input_post; ?>",
				job_city: "<?php echo $input_city; ?>",
				job_email: {
					required:"<?php echo $input_email; ?>",
					email:"<?php echo $input_email_invalid; ?>"
				},
				job_confirmemail: "<?php echo $input_confirmemail; ?>",
				job_tel: "<?php echo $input_tel; ?>",
				job_address1: "<?php echo $input_address1; ?>",
				job_post1: "<?php echo $input_post1; ?>",
				job_city1: "<?php echo $input_city1; ?>",
				accept_rule: "<?php echo $job_rule; ?>"
				
			}/*,
      		submitHandler: function() { 
			 	alert(jQuery("#opretOpgavebeskrivelseForm").serialize()); 
			}*/
		});
        close_popup=function(){		
		
    		var fel=$('#f_focus').html();            
    		$('#' + fel ).focus();			
      };
      reset_form=function(){
            document.forms[0].reset()
      };
      
	});

</script>
<input class="btnhidden thickbox flr" alt="#TB_inline?height=125&width=260&inlineId=tilmeldConfirm" type="hidden" value="Godkend" />
<div id="tilmeldConfirm" style="display:none;">
	<div class="content-view">
 	<span id="f_focus" style="display:none;"></span>
    <h2 class="blue-txt center"></h2>
    <p class="message" id="msgbox"></p>
    </div>
</div> 
<input style="display:none" class="button send-btn thickbox flr" id="msg_thanks" alt="#TB_inline?height=220&width=490&inlineId=opretOpgaverConfirm" type="button" value="Godkend" />
<div id="opretOpgaverConfirm" class="content-inner w400" style="display:none;">
    <h2 class="blue-txt">Din maleropgave er nu oprettet</h2>
    <div class="content-view">
        <p>Din maleropgave er nu oprettetog vil blive formidlet videre til vores netværk af malerfirmaer. Op til tre firmaer vil modtage din opgave og kontakte dig med henblik på afgivelse af uforpligtende tilbud. </p>
        <p>Der er sendt en e-mail til <?php echo $receivedemail ;?> med en kopi af din oprettede maleropgave samt information om det videre forløb.</p>
        
    </div>
</div>

<div class="inner clearfix">
                        <!-- Tilmeld Malerfirma Form-->
                        <?php $info = getArticle(22);
							  $images = json_decode($info->images);
						?>
                       
                        <div class="content-decoration w975 h670 bor-std" style=" <?php if (is_file($images->image_intro)) {echo "background: url('".$images->image_intro."') no-repeat scroll right bottom #FFFFFF;";} else {echo "background: url('templates/3dmaler/img/main-img-bg.jpg') no-repeat scroll right bottom #FFFFFF;";} ;?>  ">
                        	<div class="content-inner">
                                <div class="content-view w520">
                                    <h2 class="blue-txt">Dine kontaktinformationer:</h2>
                                    <form id="opretOpgaverKontaktInfoForm" class="tilmeld-form" method="post" action="">
                                        <fieldset>
                                            <div class="input-set-ctn">
                                            	<script type="text/javascript">
													
													function toggleDiv(otherAddress) {
													   $("#otherAddress, #profession").toggle();
													}
													function resetDiv() {
													   $("#otherAddress, #profession").hide();
													}
												</script>
                                            	<p class="input-set">
                                                	<label></label>
                                                	<label class="check-box"><input class="check-box" type="radio" name="usertype" value="0" onchange='$("#profession").hide();' checked="checked" id="usertype1" /> Privat</label>
                                                    <label class="check-box"><input class="check-box" type="radio" name="usertype" value="1" onchange='$("#profession").show();' id="usertype2" /> Erhverv</label>
                                                </p>
                                                <div id="profession" style="display:none">
                                                	<p class="input-set">
                                                        <label>Firma navn<span>*</span></label>
                                                        <input class="input-txt" type="text" name="job_company" id="job_company" value="" />
                                                    </p>
                                                </div>
                                            	<p class="input-set">
                                                	<label>Fornavn<span>*</span></label>
                                                	<input class="input-txt" type="text"  name="job_firstname" id="job_firstname"  value="" />
                                                </p>
                                                <p class="input-set">
                                                	<label>Efternavn<span>*</span></label>
                                                	<input class="input-txt" type="text" name="job_lastname" id="job_lastname" value="" />
                                                </p>
                                                <p class="input-set">
                                                	<label>Adresse<span>*</span></label>
                                                	<input class="input-txt" type="text" name="job_address" id="job_address" value="" />
                                                </p>
                                                <p class="input-set">
                                                	<label>Postnr/By<span>*</span></label>
                                                	<input class="input-txt post-num" type="text" title="Postnr.*" name="job_post" id="job_post" value="" />
                                                	<input class="input-txt city" type="text" title="By*" name="job_city" id="job_city" value="" />
                                                </p>
                                                <p class="input-set  mart15">
                                                	<label>E-mail<span>*</span></label>
                                                	<input class="input-txt" type="text" name="job_email" id="job_email" value="" />
                                                </p>
                                                <p class="input-set">
                                                	<label>Gentag E-mail<span>*</span></label>
                                                	<input class="input-txt" type="text" name="job_confirmemail" id="job_confirmemail" value="" />
                                                </p>
                                                <p class="input-set">
                                                	<label>Telefonnummer<span>*</span></label>
                                                	<input class="input-txt short" type="text" name="job_tel" id="job_tel" value="" />
                                                </p>
                                                
                                                <p class="input-set">
                                                	<label>Skal arbejdet udføres på ovenstående adresse?<span>*</span></label>
                                                	<label class="check-box"><input class="check-box" type="radio" name="job_workataddress" id="job_workataddress1" onchange='$("#otherAddress").hide();' checked="checked" value="1" /> Ja</label>
                                                    <label class="check-box"><input class="check-box" type="radio"  name="job_workataddress" value="0" id="job_workataddress2" onchange='$("#otherAddress").show();' /> Nej</label>
                                                </p>
                                                <div id="otherAddress" class="padt10" style="display:none">
                                                	<p class="input-set">
                                                        <label>Arbejdet skal udføres på denne adresse<span>*</span></label>
                                                        <input class="input-txt" type="text" name="job_address1" id="job_address1" value="" />
                                                    </p>
                                                    <p class="input-set post">
                                                    	<input class="input-txt post-num" type="text" title="Postnr.*"  name="job_post1" id="job_post1" value="" />
                                                    </p>
                                                    <p class="input-set city">	
                                                    	<input class="Input-txt city" type="text" title="By*" name="job_city1" id="job_city1" value="" />
                                                    </p>
                                                </div>
                                                <?php
												$items = getArticles(33);
												$slug = $items[0]->id.':'.$items[0]->alias;
												$catslug =$items[0]->catid ? $items[0]->catid .':'.$items[0]->category_alias : $items[0]->catid;
												require_once JPATH_SITE.'/components/com_content/helpers/route.php';
												$readmore = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug));
                                                ?>
                                                <p class="input-set accept"><label class="check-box"><input class="check-box" type="checkbox" id="accept_rule" name="accept_rule" />Jeg accepterer <a href="<?php echo $readmore;?>" target="_blank">brugerbetingelserne.</a></label></p>
                                                
                                            </div>
                                            
                                            <div class="form-submit padt15">
                                            	<input class="button back-btn fll" type="button" value="Tilbage" onclick="javascript:history.back();" />
                                                <input class="button reset-btn flr" onclick="resetDiv();" type="reset" value="Nulstil" />
                                                <input class="button send-btn flr" onclick="$('#opretOpgaverKontaktInfoForm').submit();"  type="button" value="Godkend" />
                                                <input type="hidden" name="option" value="com_jobs" />
                                                <input type="hidden" name="view" value="register" />
                                                <input type="hidden" name="task" value="job_step_second" />
                                                <?php echo JHtml::_( 'form.token' ); ?>
                                            </div>	                                            
                                        </fieldset>
                                    </form>
                                </div>
                        	</div>
                        </div>
                        <!-- /Tilmeld Malerfirma Form-->
                        
                    </div>